﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlTypes;
using System.Linq;
using System.Text;


namespace nadModel
{
    public class DbTypeHelper
    {
        public static byte[] GetBytes(object o)
        {
            return (byte[])o;
        }
        public static SqlDateTime GetSqlDateTime(IDataReader reader, int pos)
        {
            if (!reader.IsDBNull(pos))
            {
                return new SqlDateTime(reader.GetDateTime(pos));
            }
            return SqlDateTime.Null;
        }

        public static string GetString(object o)
        {
            if ((o == null) || (o is DBNull))
            {
                return null;
            }
            if (o is SqlDateTime)
            {
                SqlDateTime time3 = (SqlDateTime)o;
                SqlDateTime time5 = (SqlDateTime)o;
                return (time3.Value.ToString("yyyy-MM-dd HH:mm:ss") + "." + time5.Value.Millisecond.ToString("0##"));
            }
            if (o is DateTime)
            {
                DateTime time = (DateTime)o;
                DateTime time2 = (DateTime)o;
                return (time.ToString("yyyy-MM-dd HH:mm:ss") + "." + time2.Millisecond.ToString("0##"));
            }
            return o.ToString();
        }
    }
}
